package com.xy.blog.zuul.swagger2;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author zanhonglei
 * @version V1.0
 * @Description:
 * @date 2019/11/10 6:10 下午
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {

    @Value("${swagger2.enable:false}")
    protected boolean swagger2Enable ;

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .enable(swagger2Enable)
                .apiInfo(apiInfo());
    }

    /**
     * 创建改API的基本信息（这些基本信息会展示在文档页面中）
     * 访问地址： http://项目实际地址/swagger-ui.html
     * @return
     */
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("XYBLOG 博客 API")
                .description("博客地址：http://www.xyblog.vip")
                .termsOfServiceUrl("http://www.xyblog.vip")
                .contact(new Contact("XYBLOG","http://www.xyblog.vip","firelife_it@163.com"))
                .version("1.0")
                .build();
    }

}